package org.mushroomdb.security;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Tomas
 *
 * Es el encargado de dado un permiso, devolver su codigo
 * 
 */
public class PermissionHelper implements PermissionHelperKeys{
    
    private static PermissionHelper instance;
    private Map<String, Integer> permissionMap = new HashMap<String, Integer>();
    
    private PermissionHelper(){
        this.permissionMap.put(SELECT,new Integer(0));
        this.permissionMap.put(INSERT,new Integer(1));
        this.permissionMap.put(UPDATE,new Integer(2));
        this.permissionMap.put(DELETE,new Integer(3));
        this.permissionMap.put(GRANT,new Integer(4));
        this.permissionMap.put(CREATE_TABLE,new Integer(5));
        this.permissionMap.put(DROP_TABLE,new Integer(6));
        this.permissionMap.put(REVOKE,new Integer(7));
        
    }
    
    public  static PermissionHelper getInstance(){
        if(instance==null){
           instance = new PermissionHelper();
        }
        return instance;
    }
    
    public int getCode(String permissionName){
        Integer integer = this.permissionMap.get(permissionName);
        return integer.intValue();
    }
    

}
